//package com.ionehe.autoconfigure;
//
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.autoconfigure.AutoConfigureAfter;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.core.io.support.ResourcePatternResolver;
//
//import javax.annotation.Resource;
//import javax.sql.DataSource;
//
//@Configuration
//@AutoConfigureAfter(value = {RabbitProducerDataSourceConfiguration.class})
//public class RabbitProducerMyBatisConfiguration {
//
//    static final String PACKAGE = "com.ionehe.dao";
//    static final String MAPPER_LOCATION = "classpath:com/ionehe/dao/*.xml";
//
//    //@Bean(name="rabbitProducerSqlSessionFactory")
//    //public SqlSessionFactory rabbitProducerSqlSessionFactory(DataSource rabbitProducerDataSource) {
//    //
//    //    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
//    //    bean.setDataSource(rabbitProducerDataSource);
//    //    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//    //    try {
//    //        bean.setMapperLocations(resolver.getResources("classpath:com/ionehe/dao/*.xml"));
//    //        SqlSessionFactory sqlSessionFactory = bean.getObject();
//    //        sqlSessionFactory.getConfiguration().setCacheEnabled(Boolean.TRUE);
//    //        return sqlSessionFactory;
//    //    } catch (Exception e) {
//    //        throw new RuntimeException(e);
//    //    }
//    //}
//    //
//    //@Bean(name = "rabbitProducerSqlSessionFactory")
//    //@Primary
//    //public SqlSessionFactory brmSqlSessionFactory(@Qualifier("rabbitProducerDataSource") DataSource brmDataSource)
//    //        throws Exception {
//    //    final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
//    //    sessionFactory.setDataSource(brmDataSource);
//    //    sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
//    //            .getResources(MAPPER_LOCATION));
//    //    return sessionFactory.getObject();
//    //}
//
//    //@Bean(name="rabbitProducerSqlSessionTemplate")
//    //public SqlSessionTemplate rabbitProducerSqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
//    //    return new SqlSessionTemplate(sqlSessionFactory);
//    //}
//
//}